package dimensional.traveler.client;

import com.google.gwt.user.client.Cookies;

public class UserManagement {
	
	private static final String COOKIE_NAME = "dt-user";
	
	private static String user;
	
	public static boolean isUserLoggedIn() {
		return Cookies.getCookie(COOKIE_NAME) != null && !Cookies.getCookie(COOKIE_NAME).equals("");
	}
	
	public static String getLoggedInUser() {
		if (user == null) {
			user = Cookies.getCookie(COOKIE_NAME);
		}
		return user;
	}
	
	public static void setLoggedInUser(String userId) {
		user = userId;
		Cookies.setCookie(COOKIE_NAME, userId);
	}
	
	public static void logoutUser() {
		user = null;
		Cookies.removeCookie(COOKIE_NAME);
	}
	
}
